<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [];
        for (let i = 0; i < 20; i++) {
            arr.push(Math.round(Math.random()*100));
            
        }

        function selectionSort(arr){
            let minIndex;
            for (let i = 0; i < arr.length; i++) {
                minIndex = i;
                for (let j = i+1; j < arr.length; j++) {
                    if(arr[j]<arr[minIndex]){
                        minIndex = j;
                    }
                }
                if(minIndex!==i){
                    [arr[i],arr[minIndex]] = [arr[minIndex],arr[i]];
                }
            }

            return arr;
        }

        console.log(selectionSort(arr));
    </script>
</body>
</html>